﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using Domain.Entity;

namespace Domain.DAL
{
    public class AdminsDAL : DALBase
    {
        /// <summary>
        /// 自定义数据库链接字符串
        /// </summary>
        public AdminsDAL() : base("Other_MySQLDB") { }

        /// <summary>
        /// 从默认数据库中获取
        /// </summary>
        /// <returns></returns>
        public IList<Admins> GetList()
        {
            string sql = "SELECT * FROM Admins";
            using (DbCommand cmd = db.GetSqlStringCommand(sql))
            {
                return base.ExecuteReaderList<Admins>(cmd);
            }
        }

        /// <summary>
        /// 从Other_MySQLDB链接字符串中所设置的数据库中获取
        /// </summary>
        /// <returns></returns>
        public IList<Admins> GetList_ByOtherConnection()
        {
            string sql = "SELECT Host AS Power,User,Password AS Sex FROM User;";
            using (DbCommand cmd = db.GetSqlStringCommand(sql))
            {
                return base.ExecuteReaderList<Admins>(cmd);
            }
        }
    }
}
